﻿$(document).ready(function() {
    $.widget("ui.simpledialog", $.ui.dialog, {
        _create: function () {
            $.ui.dialog.prototype._create.apply(this);
            var self = this,
            options = self.options,
			title = options.title || '&#160;',
			titleId = $.ui.dialog.getTitleId(self.element),
            uiDialog = self.uiDialog,
			uiDialogContent = self.element,
		    uiDialogTitlebar = self.uiDialogTitlebar,
            uiDialogTitlebarCloseText = self.uiDialogTitlebarCloseText,
            uiDialogTitle = $('#' + titleId),
            uiDialogTitlebarClose = uiDialogTitle.next();

            uiDialogTitlebar.hide();
            uiDialogTitlebarClose = $('<a href="#"></a>')
				.addClass(
					'ui-dialog-titlebar-close ' +
					'ui-corner-all'
				)
				.attr('role', 'button')
				.hover(
					function () {
					    uiDialogTitlebarClose.addClass('ui-state-hover');
					},
					function () {
					    uiDialogTitlebarClose.removeClass('ui-state-hover');
					}
				)
				.focus(function () {
				    uiDialogTitlebarClose.addClass('ui-state-focus');
				})
				.blur(function () {
				    uiDialogTitlebarClose.removeClass('ui-state-focus');
				})
				.click(function (event) {
				    self.close(event);
				    return false;
				})
				.prependTo(uiDialog);
        }
    });
});